<?php

/**
 * Framework_Util
 *
 * @author      Ian Szewczyk <roamzero@gmail.com>
 * @copyright   (c) 2007 Ian Szewczyk. All rights reserved.
 * @license     http://www.opensource.org/licenses/bsd-license
 * @package Framework
 * @filesource
 */



	 
/**
 * Framework_Util
 *
 * This is a basic class designed so that coders
 * can call basic utility, or 'helper' functions in their modules. The naming 
 * convention for calling functions extended beyond this class 
 * is $this->util->'file'_'function'(args), where file.php will be loaded from
 * the Util directory and 'function' will be called
 *
 * @author Ian Szewczyk <roamzero@gmail.com>
 * @package Framework
 * @todo Make it work with reference arguments
 */
class Framework_Util 
{
 	private $includedFiles = array();
	
	public function __construct()
 	{
 		//parent::__construct();
 	}
 	
	public function __call($function, $args = null) {
    	$function = explode('_',$function);
    	if (!in_array($function[0],$this->includedFiles)) {
    		$this->includedFiles[] = $function[0];
    		include(FRAMEWORK_BASE_PATH.'/Framework/Util/'.array_shift($function).'.php');
    	}
    	
		if ($args == null)
			return call_user_func(array_pop($function));
		else	
    		return call_user_func_array(array_pop($function),$args);
    }

}

?>